<template>
  <div id="nenghaofenxi">
    <div><h2 style="text-align: center">能耗分析</h2></div>
    <div style="background-color: #F7F7F7;">
      <el-form v-for="(item,index) in nenghaoCpData" :model="item" ref="addFormRef2"  :inline="true" style="background-color: #F7F7F7;">
      <el-form-item label="产品" prop="chanpingName">
        <el-select v-model="item.chanpingName" filterable placeholder="请选择产品"  style="width: 100%" @change="chanpingChange($event,item)" >
          <el-option
            v-for="itemcp in chanpingData"
            :key="itemcp.id"
            :label="itemcp.productName+'('+itemcp.serialNum+')'"
            :value="{value:itemcp.id,label:itemcp.productName,itemcp:itemcp}">
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="数量"  prop="chanpingNum">
        <el-input v-model="item.chanpingNum"  ></el-input>
      </el-form-item>
      <el-form-item label="分级判定标准:" prop="chanpingName" >
        <span style="color: #34E6B6;font-size: 22px">5000 </span ><span style="font-size: 17px">(吨标煤)</span>
      </el-form-item>
        <el-form-item prop="chanpingName" style="margin-left: 80px">
       <div  style="float: right;display: flex;justify-content:space-between">
        <div>
        <span style="font-size: 19px;"><span style="color: red">分析结果</span>---按单位产品能耗限额估算标煤量（吨）：</span>
        <span style="color:#34E6B6;font-size: 22px;">{{(item.chanpingValue*item.chanpingNum/item.estimateAmount).toFixed(2)}}</span>
        </div>
        <div style="margin-left: 80px">
          <el-tooltip class="item" effect="dark" content="删除产品" placement="bottom">
            <img src="../../assets/img/imge/删除.png" style="cursor: pointer;height: 32px;width: 32px" @click="removeChanping(item)">
          </el-tooltip>
        </div>
      </div>
        </el-form-item>
      <div style="float: right;margin-right: 10%;margin-top: 10px;">
      </div>
    </el-form>
    </div>
    <div style="background-color: #eff6fb;padding-bottom: 10px ">
      <span style="color: red;font-size: 20px">(准入值估算)</span><span style="font-size: 18px">按单位产品能耗限额估算标煤量总计（吨）:</span><span style="color: red;font-size: 22px">{{zhunruzhi}}</span>
    </div>
    <div  style="text-align: center;color: #34E6B6;font-size: 20px" >
      <i class="el-icon-circle-plus-outline" @click="addChanping()" style="cursor: pointer"></i> <a @click="addChanping()"  style="cursor: pointer">新增产品</a>
    </div>
    <el-form v-for="(item,index) in nenghaoData" :model="item" ref="addFormRef2"  :inline="true" style="background-color: #F7F7F7;">
    <el-divider content-position="left">消费量(入厂)物质</el-divider>
      <el-form-item label="种类:"  style="margin-left: 20px">
        <el-tag style="font-size: 16px;">耗能工质</el-tag>
        <el-tooltip class="item" effect="dark" content="添加该类物质" placement="bottom">
          <el-button icon="el-icon-plus" circle size="mini" style="margin-left: 5px;margin-top: 3px;color: #34E6B6" @click="addWuziHaoneng(item)"> </el-button>
        </el-tooltip>
      </el-form-item>
      <div style="margin-top: -25px">
        <div v-for="(item2,index2) in item.haonengwuziData" style="margin-top: -5px">
          <el-form-item label="物质"  style="margin-left: 200px">
            <el-select v-model="item2.name" filterable placeholder="请选择物质"  style="width: 92%" @change="wuziChange($event,item2)" >
              <el-option
                v-for="itemWz in zlwuziData1"
                :key="itemWz.id"
                :label="itemWz.substance+'('+itemWz.substanceUnit+')'"
                :value="{value:itemWz.id,label:itemWz.substance,item:itemWz}">
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="用量"   >
            <el-input v-model="item2.num"  ></el-input>
          </el-form-item>
          <el-tooltip class="item" effect="dark" content="删除该行物质" placement="bottom">
            <el-button icon="el-icon-minus" circle size="small" style="margin-left: -10px;margin-top: 3px" @click="removeWuzihaoneng(item,item2)"> </el-button>
          </el-tooltip>
        </div>
      </div>
      <el-form-item label="种类:"  style="margin-left: 20px">
        <el-tag style="font-size: 16px;">各种能源</el-tag>

        <el-tooltip class="item" effect="dark" content="添加该类物质" placement="bottom">
          <el-button icon="el-icon-plus" circle size="mini" style="margin-left: 5px;margin-top: 3px;color: #34E6B6" @click="addWuzinengyuan(item)"> </el-button>
        </el-tooltip>
      </el-form-item>
      <div style="margin-top: -25px">
        <div v-for="(item2,index2) in item.nengyuanwuziData" style="margin-top: -5px">
          <el-form-item label="物质" style="margin-left: 200px">
            <el-select v-model="item2.name" filterable placeholder="请选择物质"  style="width: 92%" @change="wuziChange($event,item2)" >
              <el-option
                v-for="itemWz in zlwuziData2"
                :key="itemWz.id"
                :label="itemWz.substance+'('+itemWz.substanceUnit+')'"
                :value="{value:itemWz.id,label:itemWz.substance,item:itemWz}">
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="用量"  >
            <el-input v-model="item2.num"  ></el-input>
          </el-form-item>
          <el-tooltip class="item" effect="dark" content="删除该行物质" placement="bottom">
            <el-button icon="el-icon-minus" circle size="small" style="margin-left: -10px;margin-top: 3px" @click="removeWuzinengyuan(item,item2)"> </el-button>
          </el-tooltip>
        </div>
      </div>
      <el-form-item label="种类:"  style="margin-left: 20px">
        <el-tag style="font-size: 16px;">电力和热力</el-tag>
        <!-- <el-select v-model="item2.type" filterable placeholder="请选择种类"  style="width: 92%" @change="zhongleiChange" >
           <el-option
             v-for="itemZl in zhongleiData"
             :key="itemZl.id"
             :label="itemZl.categoryName"
             :value="{value:itemZl.id,label:itemZl.categoryName}">
           </el-option>
         </el-select>-->
        <el-tooltip class="item" effect="dark" content="添加该类物质" placement="bottom">
          <el-button icon="el-icon-plus" circle size="mini" style="margin-left: 5px;margin-top: 3px;color: #34E6B6" @click="addWuziredian(item)"> </el-button>
        </el-tooltip>
      </el-form-item>
      <div style="margin-top: -25px">
        <div v-for="(item2,index2) in item.redianwuziData" style="margin-top: -5px">
          <el-form-item label="物质"  style="margin-left: 200px">
            <el-select v-model="item2.name" filterable placeholder="请选择物质"  style="width: 92%" @change="wuziChange($event,item2)" >
              <el-option
                v-for="itemWz in zlwuziData3"
                :key="itemWz.id"
                :label="itemWz.substance+'('+itemWz.substanceUnit+')'"
                :value="{value:itemWz.id,label:itemWz.substance,item:itemWz}">
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="用量" >
            <el-input v-model="item2.num"  ></el-input>
          </el-form-item>
          <el-tooltip class="item" effect="dark" content="删除该行物质" placement="bottom">
            <el-button icon="el-icon-minus" circle size="small" style="margin-left: -10px;margin-top: 3px" @click="removeWuziredian(item,item2)"> </el-button>
          </el-tooltip>
        </div>
      </div>
      <el-divider content-position="left">外送量(出厂)物质</el-divider>
      <el-form-item label="种类:"   style="margin-left: 20px"  >
        <el-tag style="font-size: 16px;">各种能源</el-tag>
        <el-tooltip class="item" effect="dark" content="添加该类物质" placement="bottom">
          <el-button icon="el-icon-plus" circle size="mini" style="margin-left: 5px;margin-top: 3px;color: #34E6B6" @click="addwuzijiannengyuan(item)"> </el-button>
        </el-tooltip>
      </el-form-item>
      <div style="margin-top: -25px">
        <div v-for="(item3,index3) in item.xiaohaoDatanengyuan" style="margin-top: -5px">
          <el-form-item label="物质"  style="margin-left: 200px">
            <el-select v-model="item3.name" filterable placeholder="请选择物质"  style="width: 92%" @change="wuziChange($event,item3)" >
              <el-option
                v-for="itemWz2 in zlwuziData2"
                :key="itemWz2.id"
                :label="itemWz2.substance+'('+itemWz2.substanceUnit+')'"
                :value="{value:itemWz2.id,label:itemWz2.substance,item:itemWz2}">
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="用量"  >
            <el-input v-model="item3.num"  ></el-input>
          </el-form-item>
          <el-tooltip class="item" effect="dark" content="删除该行物质" placement="bottom">
            <el-button icon="el-icon-minus" circle size="small" style="margin-left: -10px;margin-top: 3px" @click="removeWuzi2nengyuan(item,item3)"> </el-button>
          </el-tooltip>
        </div>
      </div>
      <el-form-item label="种类:"   style="margin-left: 20px"  >
        <el-tag style="font-size: 16px;">热力和电力</el-tag>
        <el-tooltip class="item" effect="dark" content="添加该类物质" placement="bottom">
          <el-button icon="el-icon-plus" circle size="mini" style="margin-left: 5px;margin-top: 3px;color: #34E6B6" @click="addwuzijianredian(item)"> </el-button>
        </el-tooltip>
      </el-form-item>
      <div style="margin-top: -25px">
        <div v-for="(item3,index3) in item.xiaohaoDataredian" style="margin-top: -5px">
          <el-form-item label="物质"  style="margin-left: 200px">
            <el-select v-model="item3.name" filterable placeholder="请选择物质"  style="width: 92%" @change="wuziChange($event,item3)" >
              <el-option
                v-for="itemWz2 in zlwuziData3"
                :key="itemWz2.id"
                :label="itemWz2.substance+'('+itemWz2.substanceUnit+')'"
                :value="{value:itemWz2.id,label:itemWz2.substance,item:itemWz2}">
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="用量"  >
            <el-input v-model="item3.num"  ></el-input>
          </el-form-item>
          <el-tooltip class="item" effect="dark" content="删除该行物质" placement="bottom">
            <el-button icon="el-icon-minus" circle size="small" style="margin-left: -10px;margin-top: 3px" @click="removeWuzi2redian(item,item3)"> </el-button>
          </el-tooltip>
        </div>
      </div>
    </el-form>
    <div  style="text-align: center">
      <el-button @click="chongzhi">重 置</el-button>
      <el-button type="primary" @click="nenghaofenxi">确 定</el-button>
      <!--<el-button type="primary" @click="printOut('daochu')">导 出</el-button>-->
    </div>
    <div  style="background-color: #eff6fb;margin-top: 10px">
      <span style="font-size: 18px;color:red"><span style="color: red;font-size: 20px">(折标系数法估算)</span>分析结果</span>
      <el-table
        :data="fenxiresult"
        :header-cell-style="{background:'#eff6fb',color:'black'}"
        style="width: 100%;background-color: #eff6fb;">
        <el-table-column
          prop="nenghao"
          label="能耗"
          width="220">
        </el-table-column>
        <el-table-column
          prop="dangliang"
          label="当量值"
          width="220">
        </el-table-column>
        <el-table-column
          prop="dengjia"
          label="等价值"
          width="220">
        </el-table-column>
      <!--  <el-table-column
          prop="biaozhun"
          label="分级判断标准"
          width="200">
        </el-table-column>-->
        <el-table-column
          prop="unit"
          label="单位"
          width="130">
        </el-table-column>
       <!-- <el-table-column
          prop="result"
          label="当量值分级判断结果"
          width="240"
        >
          <template v-slot="scope">
            <span v-if="scope.row.dangliang>50000" style="color: red">
              超过分级判断标准
            </span>
            <span v-else-if="scope.row.dangliang==50000" style="color: orange">
               等于分级判断标准
            </span>
            <span v-else="scope.row.dangliang<50000" style="color: greenyellow">
               小于分级判断标准
            </span>
          </template>
        </el-table-column>-->
      <!--  <el-table-column
          prop="result"
          label="等价值分级判断结果"
        >
          <template v-slot="scope">
            <span v-if="scope.row.dengjia>50000" style="color: red">
              超过分级判断标准
            </span>
            <span v-else-if="scope.row.dengjia==50000" style="color: orange">
               等于分级判断标准
            </span>
            <span v-else="scope.row.dengjia<50000" style="color: greenyellow">
               小于分级判断标准
            </span>
          </template>
        </el-table-column>-->
      </el-table>

    </div>
  </div>
</template>

<script>
  import html2canvas from 'html2canvas';
  export default {
    name: 'nenghaofenxi',
    data(){
      return{
        nenghaoCpData:[{
          chanpingName: '',
          chanpingNum: '',
          chanpingValue: 0,
          estimateAmount: 1,
        }
        ],
        nenghaoData:[
          {
            wuziData:[],
            haonengwuziData: [{
              name: '',
              type: '1',
              num: '',
            }],
            nengyuanwuziData: [{
              name: '',
              type: '2',
              num: '',
            }],
            redianwuziData: [{
              name: '',
              type: '3',
              num: '',
            }],
            xiaohaoData:[],
            xiaohaoDatanengyuan:[{
              name: '',
              type: '2',
              num: '',
            }],
            xiaohaoDataredian:[{
              name: '',
              type: '3',
              num: '',
            }],
          }
        ],
        nenghaoFormRule:{
        },
        chanpingData:[],
        zhongleiData:[],
        zlwuziData1:[],
        zlwuziData2:[],
        zlwuziData3:[],
        zlwuziDataJian:[],
        fenxiresult:[],
        dangliangALL:0,
        dengjiaALL:0,
        nengyuandangliangALL:0,
        nengyuandengjiaALL:0,
        dangliangjianALL:0,
        dengjiajianALL:0,
        zhonghenenghaodangliang:0,
        zhonghenenghaodengjia:0,
        zhonghenengyuandangliang:0,
        zhonghenengyuandengjia:0,
        nengyuanhejidangliang:0,
        nengyuanhejidengjia:0,
      }
    },
    methods:{
      async getAllproduct(){
        const {data:result}= await this.$http.get('/v1.0/resultIntegration/rule/admittanceValue/findAll')
        if(result.status=='3000'){
          this.chanpingData=result.data
        }else {
          this.chanpingData=[]
        }
        const {data:result2}= await this.$http.get('/v1.0/resultIntegration/rule/substanceParam/findAll')
        if(result2.status=='3000'){
          this.zhongleiData=result2.data
        }else {
          this.zhongleiData=[]
        }
      },
      async wzzhongleiChange(){
        const {data:result}= await this.$http.get('/v1.0/resultIntegration/rule/substanceParam/findAllByParentId/1')
        if(result.status=='3000'){
          this.zlwuziData1=result.data
        }else {
          this.zlwuziData1=[]
        }
        const {data:result2}= await this.$http.get('/v1.0/resultIntegration/rule/substanceParam/findAllByParentId/2')
        if(result2.status=='3000'){
          this.zlwuziData2=result2.data
        }else {
          this.zlwuziData2=[]
        }const {data:result3}= await this.$http.get('/v1.0/resultIntegration/rule/substanceParam/findAllByParentId/3')
        if(result3.status=='3000'){
          this.zlwuziData3=result3.data
        }else {
          this.zlwuziData3=[]
        }
      },
      async chanpingChange(obj,item){
        item.chanpingValue=Number(obj.itemcp.admittanceValue)
        item.estimateAmount=Number(obj.itemcp.estimateAmount)
      },
      addChanping(){
        this.nenghaoCpData.push({
          chanpingName: '',
          chanpingNum: '',
          chanpingValue: 0,
          estimateAmount: 1})
      },
      removeChanping(item){
          for(let i in this.nenghaoCpData){
            if (this.nenghaoCpData[i] == item) {
              this.nenghaoCpData.splice(i, 1);
            }
        }
      },
      addWuziHaoneng(obj){
        obj.haonengwuziData.push({
          name:'',
          type:'1',
          num:'',
        })
      },
      addWuzinengyuan(obj){
        obj.nengyuanwuziData.push({
          name:'',
          type:'2',
          num:'',
        })
      },
      addWuziredian(obj){
        obj.redianwuziData.push({
          name:'',
          type:'3',
          num:'',
        })
      },
      addwuzijiannengyuan(obj){
        obj.xiaohaoDatanengyuan.push({
          name:'',
          type:'2',
          num:'',
        })
      },
      addwuzijianredian(obj){
        obj.xiaohaoDataredian.push({
          name:'',
          type:'3',
          num:'',
        })
      },
      wuziChange(obj,item2){
        item2['conversionCoefficient'] = obj.item.conversionCoefficient
        item2['conversionCoefficientUnit'] = obj.item.conversionCoefficientUnit
        item2['lowCalorific'] = obj.item.lowCalorific
        item2['lowCalorificUnit'] = obj.item.lowCalorificUnit
        item2['substance']=obj.item.substance
      },
      removeWuzihaoneng(item,item2){
        for(let i in item.haonengwuziData){
          if (item.haonengwuziData[i] == item2) {
            item.haonengwuziData.splice(i, 1);
          }
        }
      },
      removeWuzinengyuan(item,item2){
        for(let i in item.nengyuanwuziData){
          if (item.nengyuanwuziData[i] == item2) {
            item.nengyuanwuziData.splice(i, 1);
          }
        }
      },
      removeWuziredian(item,item2){
        for(let i in item.redianwuziData){
          if (item.redianwuziData[i] == item2) {
            item.redianwuziData.splice(i, 1);
          }
        }
      },
      removeWuzi2nengyuan(item,item3){
        for(let i in item.xiaohaoDatanengyuan){
          if (item.xiaohaoDatanengyuan[i] == item3) {
            item.xiaohaoDatanengyuan.splice(i, 1);
          }
        }
      },
      removeWuzi2redian(item,item3){
        for(let i in item.xiaohaoDataredian){
          if (item.xiaohaoDataredian[i] == item3) {
            item.xiaohaoDataredian.splice(i, 1);
          }
        }
      },
      nenghaofenxi(){
        var haoneng=0,nengyuan=0,dianlidengliang=0,dianlidangliang=0,relidangliang=0;
        var nengyuanjian=0,dianlidengliangjian=0,dianlidangliangjian=0,relidangliangjian=0
        for(let x in this.nenghaoData){
          this.nenghaoData[x].wuziData=this.nenghaoData[x].haonengwuziData.concat(this.nenghaoData[x].nengyuanwuziData).concat(this.nenghaoData[x].redianwuziData)
          for(let i in this.nenghaoData[x].wuziData){
            if(this.nenghaoData[x].wuziData[i].type==1 && this.nenghaoData[x].wuziData[i].num!=''){
              haoneng+=(Number(this.nenghaoData[x].wuziData[i].num)*Number(this.nenghaoData[x].wuziData[i].conversionCoefficient))
            }else if(this.nenghaoData[x].wuziData[i].type==2  && this.nenghaoData[x].wuziData[i].num!=''){
              nengyuan+=(Number(this.nenghaoData[x].wuziData[i].num)*Number(this.nenghaoData[x].wuziData[i].conversionCoefficient))
            }else if(this.nenghaoData[x].wuziData[i].type==3  && this.nenghaoData[x].wuziData[i].num!=''){
              console.log(this.nenghaoData[x].wuziData[i].substance)
              if(this.nenghaoData[x].wuziData[i].substance=='电力（当量值/等价值）') {
                console.log(this.nenghaoData[x].wuziData[i].conversionCoefficient.split('/')[0])
                dianlidangliang += (Number(this.nenghaoData[x].wuziData[i].num) * Number(this.nenghaoData[x].wuziData[i].conversionCoefficient.split('/')[0]))
                dianlidengliang += (Number(this.nenghaoData[x].wuziData[i].num) * Number(this.nenghaoData[x].wuziData[i].conversionCoefficient.split('/')[1]))
              }
              else if(this.nenghaoData[x].wuziData[i].substance=='热力（当量值）'){
                relidangliang+=(Number(this.nenghaoData[x].wuziData[i].num)*Number(this.nenghaoData[x].wuziData[i].conversionCoefficient))
              }
            }
          }
          this.nenghaoData[x].xiaohaoData=this.nenghaoData[x].xiaohaoDatanengyuan.concat(this.nenghaoData[x].xiaohaoDataredian)
          for(let j in this.nenghaoData[x].xiaohaoData){
            if(this.nenghaoData[x].xiaohaoData[j].type==2  && this.nenghaoData[x].xiaohaoData[j].num!=''){
              nengyuanjian+=(Number(this.nenghaoData[x].xiaohaoData[j].num)*Number(this.nenghaoData[x].xiaohaoData[j].conversionCoefficient))
            }else if(this.nenghaoData[x].xiaohaoData[j].type==3  && this.nenghaoData[x].xiaohaoData[j].num!=''){
              console.log(this.nenghaoData[x].xiaohaoData[j].substance)
              if(this.nenghaoData[x].xiaohaoData[j].substance=='电力（当量值/等价值）') {
                dianlidangliangjian += (Number(this.nenghaoData[x].xiaohaoData[j].num) * Number(this.nenghaoData[x].xiaohaoData[j].conversionCoefficient.split('/')[0]))
                dianlidengliangjian += (Number(this.nenghaoData[x].xiaohaoData[j].num) * Number(this.nenghaoData[x].xiaohaoData[j].conversionCoefficient.split('/')[1]))
              }
              else if(this.nenghaoData[x].xiaohaoData[j].substance=='热力（当量值）'){
                relidangliangjian+=(Number(this.nenghaoData[x].xiaohaoData[j].num)*Number(this.nenghaoData[x].xiaohaoData[j].conversionCoefficient))
              }
            }
          }
        }
        this.dangliangALL=haoneng+nengyuan+dianlidangliang+relidangliang;
        this.dengjiaALL=haoneng+nengyuan+dianlidengliang;
        this.nengyuandangliangALL=nengyuan+dianlidangliang+relidangliang;
        this.nengyuandengjiaALL=nengyuan+dianlidengliang;
        this.dangliangjianALL=nengyuanjian+dianlidangliangjian+relidangliangjian;
        this.dengjiajianALL=nengyuanjian+dianlidengliangjian;
        this.zhonghenenghaodangliang=((this.dangliangALL-this.dangliangjianALL)/1000).toFixed(4)
        this.zhonghenenghaodengjia=((this.dengjiaALL-this.dengjiajianALL)/1000).toFixed(4)
        this.zhonghenengyuandangliang=((this.nengyuandangliangALL-this.dangliangjianALL)/1000).toFixed(4)
        this.zhonghenengyuandengjia=((this.nengyuandengjiaALL-this.dengjiajianALL)/1000).toFixed(4)
        this.nengyuanhejidangliang=(this.nengyuandangliangALL/1000).toFixed(4);
        this.nengyuanhejidengjia=(this.nengyuandengjiaALL/1000).toFixed(4);
        this.fenxiresult=[]
        this.fenxiresult.push({
          'nenghao':'综合能耗',
          'dangliang':this.zhonghenenghaodangliang,
          'dengjia':this.zhonghenenghaodengjia,
          'biaozhun':'5000',
          'unit':'吨标煤'
        })
        this.fenxiresult.push({
          'nenghao':'综合能源消费量',
          'dangliang':this.zhonghenengyuandangliang,
          'dengjia':this.zhonghenengyuandengjia,
          'biaozhun':'5000',
          'unit':'吨标煤'
        })
      },
      chongzhi(){
        this.nenghaoCpData=[{
          chanpingName: '',
          chanpingNum: '',
          chanpingValue: 0,
          estimateAmount: 1,
        }];
          this.nenghaoData=[
          {
            wuziData:[],
            haonengwuziData: [{
              name: '',
              type: '1',
              num: '',
            }],
            nengyuanwuziData: [{
              name: '',
              type: '2',
              num: '',
            }],
            redianwuziData: [{
              name: '',
              type: '3',
              num: '',
            }],
            xiaohaoData:[],
            xiaohaoDatanengyuan:[{
              name: '',
              type: '2',
              num: '',
            }],
            xiaohaoDataredian:[{
              name: '',
              type: '3',
              num: '',
            }],
          }
        ];
          this.chanpingData=[],
          this.zhongleiData=[],
          this.zlwuziData1=[],
          this.zlwuziData2=[],
          this.zlwuziData3=[],
          this.zlwuziDataJian=[],
          this.fenxiresult=[],
          this.dangliangALL=0,
          this.dengjiaALL=0,
          this.nengyuandangliangALL=0,
          this.nengyuandengjiaALL=0,
          this.dangliangjianALL=0,
          this.dengjiajianALL=0,
          this.zhonghenenghaodangliang=0,
          this.zhonghenenghaodengjia=0,
          this.zhonghenengyuandangliang=0,
          this.zhonghenengyuandengjia=0,
          this.nengyuanhejidangliang=0,
          this.nengyuanhejidengjia=0
      },
      dataURLToBlob(dataurl) {//ie 图片转格式
         var arr = dataurl.split(','), mime = arr[0].match(/:(.*?);/)[1],
          bstr = atob(arr[1]), n = bstr.length, u8arr = new Uint8Array(n);
         while (n--) {
          u8arr[n] = bstr.charCodeAt(n);
        }
        return new Blob([u8arr], {type: mime})
      },
      downloadResult(name) {
        let canvasID = document.body
        let a = document.createElement('a');
        html2canvas(canvasID).then(canvas => {
          let dom = document.body.appendChild(canvas);
          dom.style.display = "none";
          a.style.display = "none";
          document.body.removeChild(dom);
          let blob = this.dataURLToBlob(dom.toDataURL("image/png"));
          a.setAttribute("href", URL.createObjectURL(blob));
          a.setAttribute("download", name + ".png")
          document.body.appendChild(a);
          a.click();
          URL.revokeObjectURL(blob);
          document.body.removeChild(a);
        });
      },
      printOut(name) {
        document.body.scrollTop = 0; // IE的
        document.documentElement.scrollTop = 0; // 其他
        this.downloadResult(name)
      },
    },
    created () {
      this.getAllproduct();
      this.wzzhongleiChange();
    },
    computed:{
      zhunruzhi:function(){
        var zhunru=0
        for(let i in this.nenghaoCpData){
          zhunru+=(this.nenghaoCpData[i].chanpingValue*this.nenghaoCpData[i].chanpingNum)/this.nenghaoCpData[i].estimateAmount
        }
        return zhunru.toFixed(2)
      }
    },
  }
</script>

<style scoped lang="less">
  #nenghaofenxi{
    position: absolute;
    left: 15.5%;
    top: 9.5%;
    bottom: 1.5%;
    width: 83.5%;
    max-height: 89%;
    overflow-y: auto;
    background-color: #eff6fb;
    border-radius: 8px;
    box-shadow: 0 0 5px #acc4fe;
    /deep/ .el-form{
      background-color: #eff6fb !important;
      margin-bottom: 10px;
      /deep/ .el-form-item{
        margin-bottom: 5px !important;
      }
      /deep/ .el-form-item__label{
        font-size: 18px;
      }
      /deep/ .el-form-item__content{
        margin-left: 0px !important;
      }
      /deep/ .el-input__inner{
        width: 90%;
        border-radius: 5px !important;
        height: 30px;
      }
      /deep/ .el-select{
        /deep/ .el-input__inner{
          width: 100%;
        }
      }
    }
  }
  /deep/ .el-divider--horizontal{
    margin: 8px 0 18px 0  !important;
  }
  /deep/ .el-divider__text{
    font-size: 18px;
  }
  /deep/ .el-table th>.cell{
    font-size: 18px;
  }
  /deep/ .el-table th,   /deep/.el-table tr{
    background-color: #eff6fb
  }
  /deep/ .el-table .cell{
    font-size: 18px;
  }
</style>
